#include <iostream>
#include <cmath>
#include "vector3.h"
using namespace std;

Vector3::Vector3() {
	x = 0; y = 0; z = 0;
}

Vector3::Vector3(double a, double b, double c) {
	x = a; y = b; z = c;
}

Vector3 Vector3::operator + (Vector3& v) {
	return Vector3(x + v.x, y + v.y, z + v.z);
}

Vector3 Vector3::operator - (Vector3& v) {
	return Vector3(x - v.x, y - v.y, z - v.z);
}

// inner product
double Vector3::operator * (Vector3& v) {
	return x * v.x + y * v.y + z * v.z;
}

Vector3 Vector3::operator * (double a) {
	return Vector3(x * a, y * a, z * a);
}

Vector3 operator * (double a, Vector3& v) {
	return Vector3(v.x * a, v.y * a, v.z * a);
}

// vector product
Vector3 Vector3::operator ^ (Vector3& v) {
	return 
		Vector3(
			y*v.z - z*v.y,
			x*v.z - z*v.x,
			x*v.y - y*v.x);
}

void Vector3::print() {
	cout << "[" << x << ", " << y << ", " << z << "]\n";
}

double Vector3::len() {
	return sqrt( (*this) * (*this) );
}

